package com.lxmes.pm.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.lxmes.common.annotation.Log;
import com.lxmes.common.core.controller.BaseController;
import com.lxmes.common.core.domain.AjaxResult;
import com.lxmes.common.enums.BusinessType;
import com.lxmes.pm.domain.AKyinfoTb;
import com.lxmes.pm.service.IAKyinfoTbService;
import com.lxmes.common.utils.poi.ExcelUtil;
import com.lxmes.common.core.page.TableDataInfo;

/**
 * 科研人员信息Controller
 * 
 * @author zhangzhiyu
 * @date 2023-04-04
 */
@RestController
@RequestMapping("/pm/aKyinfoTb")
public class AKyinfoTbController extends BaseController
{
    @Autowired
    private IAKyinfoTbService aKyinfoTbService;

    /**
     * 查询科研人员信息列表
     */
    @PreAuthorize("@ss.hasPermi('pm:aKyinfoTb:list')")
    @GetMapping("/list")
    public TableDataInfo list(AKyinfoTb aKyinfoTb)
    {
        startPage();
        List<AKyinfoTb> list = aKyinfoTbService.selectAKyinfoTbList(aKyinfoTb);
        return getDataTable(list);
    }

    /**
     * 导出科研人员信息列表
     */
    @PreAuthorize("@ss.hasPermi('pm:aKyinfoTb:export')")
    @Log(title = "科研人员信息", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, AKyinfoTb aKyinfoTb)
    {
        List<AKyinfoTb> list = aKyinfoTbService.selectAKyinfoTbList(aKyinfoTb);
        ExcelUtil<AKyinfoTb> util = new ExcelUtil<AKyinfoTb>(AKyinfoTb.class);
        util.exportExcel(response, list, "科研人员信息数据");
    }

    /**
     * 获取科研人员信息详细信息
     */
    @PreAuthorize("@ss.hasPermi('pm:aKyinfoTb:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(aKyinfoTbService.selectAKyinfoTbById(id));
    }

    /**
     * 新增科研人员信息
     */
    @PreAuthorize("@ss.hasPermi('pm:aKyinfoTb:add')")
    @Log(title = "科研人员信息", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody AKyinfoTb aKyinfoTb)
    {
        return toAjax(aKyinfoTbService.insertAKyinfoTb(aKyinfoTb));
    }

    /**
     * 修改科研人员信息
     */
    @PreAuthorize("@ss.hasPermi('pm:aKyinfoTb:edit')")
    @Log(title = "科研人员信息", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody AKyinfoTb aKyinfoTb)
    {
        return toAjax(aKyinfoTbService.updateAKyinfoTb(aKyinfoTb));
    }

    /**
     * 删除科研人员信息
     */
    @PreAuthorize("@ss.hasPermi('pm:aKyinfoTb:remove')")
    @Log(title = "科研人员信息", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(aKyinfoTbService.deleteAKyinfoTbByIds(ids));
    }
}
